<?php

/**
 * @author Home
 * @version 1.0
 * @created 20-Sep-2013 3:17:09 PM
 */
 
 include_once "../DAL/DmTrangThaiLopMon.php";
 include_once "../DAL/connect.php";
 class DmTTLopMonBLL{
     var $conn;
    function __construct(){
        $conn = new Connect();
        $conn->cnn();
    }
    
    function __destruct(){
        
    }
    public function getTTLopMonInfo(){
        $sql ="select * from dm_trangthai_lopmon";
        $result = mysql_query($sql) or die(mysql_error());
        $arr_ttlm = array();
        
        while($row = mysql_fetch_array($result)){
            $arr_ttlm[] = $this->setTTLopMon($row);            
        }
        return $arr_ttlm;
        
    }
    
    public function insertTTLopMon($ttlm){
        $sql ="INSERT INTO dm_trangthai_lopmon(
            madm_ttlm
            ,ten_ttlm
        ) VALUES (
            '".$ttlm->getmadm_ttlm()."'
            ,'".$ttlm->getten_ttlm()."' 
        )";
        $result = mysql_query($sql) or die (mysql_error());
       return $result;
    }
    
    public function updateTTLopMon($ttlm){
        $sql="UPDATE dm_trangthai_lopmon
            SET
            ten_ttlm = '".$ttlm->getten_ttlm()."' 
            WHERE madm_ttlm ='".$ttlm->getmadm_ttlm()."'";
          $result = mysql_query($sql) or die (mysql_error());
       return $result;
    }
    
    public function deleteTTLopMon($madm_ttlm){
        $sql="delete from dm_trangthai_lopmon where madm_ttlm = '".$madm_ttlm."'";
         $result = mysql_query($sql) or die (mysql_error());
       return $result;
    }
    function setTTLopMonBLL($row){
        $dmTTLopMon = new DmTrangThaiLopMon();
        $dmTTLopMon->setDmTTLopMon($row['madm_ttlm'],$row['ten_ttlm']);
        return $dmTTLopMon;
    }
    
 }
?>